# coding: utf-8

TYPE_SIZE_TABLE = {
    'BOOL': 1,        # 1 bit
    'INT': 32,        # 32 bit == 4 byte
    'STRING': 1,      # len(str)
    'LIST_INT': 32,   # len(list) * 32 bit
    'LIST_BOOL': 1,   # len(list)
    'LIST_STING': 1,  # summ all len(str) in list
}


class TypeEnum():
    UNKNOWN = 0
    BOOL = 1
    INT = 2
    ARRAY_OF_BOOL = 3
    ARRAY_OF_INT = 4
    ARRAY_OF_STRING = 5
    STRING = 6


class Type(object):
    str_mapping = {
        TypeEnum.UNKNOWN: "UNKNOWN",
        TypeEnum.BOOL: "BOOL",
        TypeEnum.INT: "INT",
        TypeEnum.ARRAY_OF_BOOL: "ARRAY_OF_BOOL",
        TypeEnum.ARRAY_OF_INT: "ARRAY_OF_INT",
        TypeEnum.ARRAY_OF_STRING: "ARRAY_OF_STRING",
        TypeEnum.STRING: "STRING",
    }

    type = None

    def __init__(self, type):
        self.type = type

    def __int__(self):
        return self.type

    def __repr__(self):
        return "<" + self.type_string() + ">"

    def type_string(self):
        """
        Возвращает строковое представление типа """
        return Type.str_mapping[self.type] or "Unknown"
